//
//  TopImageUrlZoom.m
//  yuimall_Iphone
//
//  Created by yuike6 yuike6 on 12-4-5.
//  Copyright (c) 2012年 yuike. All rights reserved.
//

#import "TopImageUrlZoom.h"
#import "header.h"

@implementation TopImageUrlZoom


+(NSString *) zoomTypeContent:(ZoomAddType) zoomType
{
    NSString * result = [[[NSString alloc] init] autorelease];
    
    switch (zoomType) {
        case ZoomAddType_InValid:
            break;
        case ZoomAddType_84:
            result = [NSString stringWithString:@"_80x40.jpg"];
            break;
            
        case ZoomAddType_63:
            result = [NSString stringWithString:@"_60x30.jpg"];
            break; 
            
        case ZoomAddType_300:
            result = [NSString stringWithString:@"_300x300.jpg"];
            break;
            
        case ZoomAddType_8165:
            result = [NSString stringWithString:@"_81x65.jpg"];
            break;
            
        case ZoomAddType_11090:
            result = [NSString stringWithString:@"_110x90.jpg"];
            break;
            
        case ZoomAddType_24:
            result = [NSString stringWithString:@"_24x24.jpg"];
            break;
            
        case ZoomAddType_30:
            result = [NSString stringWithString:@"_30x30.jpg"];
            break;
            
        case ZoomAddType_40:
            result = [NSString stringWithString:@"_40x40.jpg"];
            break;
            
        case ZoomAddType_60:
            result = [NSString stringWithString:@"_60x60.jpg"];
            break;
            
        case ZoomAddType_70:
            result = [NSString stringWithString:@"_70x70.jpg"];
            break;
            
        case ZoomAddType_100:
            result = [NSString stringWithString:@"_100x100.jpg"];
            break;
            
        case ZoomAddType_110:
            result = [NSString stringWithString:@"_110x110.jpg"];
            break;
            
        case ZoomAddType_120:
            result = [NSString stringWithString:@"_120x120.jpg"];
            break;
            
        case ZoomAddType_160:
            result = [NSString stringWithString:@"_160x160.jpg"];
            break;
            
        case ZoomAddType_170:
            result = [NSString stringWithString:@"_170x170.jpg"];
            break;
            
        case ZoomAddType_250:
            result = [NSString stringWithString:@"_250x250.jpg"];
            break;
            
        case ZoomAddType_310:
            result = [NSString stringWithString:@"_310x310.jpg"];
            break;
            
        case ZoomAddType_670:
            result = [NSString stringWithString:@"_670x670.jpg"];
            break;
            
        case ZoomAddType_62010000:
            result = [NSString stringWithString:@"_620x10000.jpg"];
            break;
            
        default:
            break;
    }
    
    return result;
}

+(NSString *) ConvertImageUrlString2ZommUrlString:(NSString *) imageUrl zoom:(ZoomAddType) zoomType
{
    if ([NSString isNilOrEmpty:imageUrl]) 
    {
        return nil;
    }
    
    if ([imageUrl endswith:@".jpg"] &&
        [imageUrl endswith:@".png"]) 
    {
        return nil;
    }
    
    
    NSString * addContent = [TopImageUrlZoom zoomTypeContent:zoomType];
    
    if ([NSString isNilOrEmpty:addContent]) 
    {
        return nil;
    }
    
    
    NSString * result = imageUrl;
    result = [result stringByAppendingString:addContent];
    
    return result;
}

+(NSURL *) ConvertImageUrlString2ZommUrl:(NSString *) imageUrl zoom:(ZoomAddType) zoomType
{
    NSString * resultString = [TopImageUrlZoom ConvertImageUrlString2ZommUrlString:imageUrl zoom:zoomType];
    
    if ([NSString isNilOrEmpty:resultString]) 
    {
        return nil;
    }
    
    return [NSURL URLWithString:resultString];
}


+(NSString *) ConvertImageUrl2ZommUrlString:(NSURL *) imageUrl 
                                       zoom:(ZoomAddType) zoomType
{
    if (!imageUrl) 
    {
        return nil;
    }
    
    
    NSString * result = [TopImageUrlZoom ConvertImageUrlString2ZommUrlString:[imageUrl absoluteString] zoom:zoomType];
    return result;
}



+(NSURL *) ConvertImageUrl2ZommUrl:(NSURL *) imageUrl 
                              zoom:(ZoomAddType) zoomType
{
    if (!imageUrl) 
    {
        return nil;
    }
    
    NSString * result = [TopImageUrlZoom ConvertImageUrl2ZommUrlString:imageUrl zoom:zoomType];
    
    if([NSString isNilOrEmpty:result])
    {
        return nil;
    }

    return [NSURL URLWithString:result];
}







@end
